<?php
if(!defined("YUEXUAN_REAL_ROOT_PATH")){
	exit("Access Denied.");
}

/**
 * Json处理类
 * @author tongjun
 *
 */
class ext_jsonHandle {
	// 以json形式输出成功消息
	public function success($msg, $otherInfo=null){
		$result = array(
				'success' => true,
				'msg' => $msg
		);
		if($otherInfo){
			$result = array_merge($result, $otherInfo);
		}
		$this->jsonOut($result);
	}
	
	// 以json形式输出错误消息
	public function error($msg){
		$result = array(
				'success' => false,
				'msg' => $msg
		);
		$this->jsonOut($result);
	}
	
	// 以json形式输出array或object
	public function jsonOut($object){
		echo json_encode($object);
		exit();
	}
}